Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Run as user#102

Merged
siegfriedweber merged 13 commits into
stackabletech:mainfrom
siegfriedweber:run_as_user
Mar 11, 2021
Merged

Run as user#102
siegfriedweber merged 13 commits into
stackabletech:mainfrom
siegfriedweber:run_as_user

Conversation

@siegfriedweber
Copy link
Copy Markdown
Member

@siegfriedweber siegfriedweber commented Mar 9, 2021

TODOs:

  • It is not checked if the user really exists. (Perhaps this should not be checked when the service unit is created. Probably it is better to just start the unit and have this information in the log output. A lot of other things can also go wrong, e.g. insufficient permissions, and then everything comes up at the same stage.)
  • Users are not created. (To be discussed if this is desired)
  • The ownership of the configuration directory is not changed. (To be discussed if this is desired)

Every state and module extracts the parts of the PodSpec it needs. Currently the systemdunit gathers the information for the service user. This user is not known in the other states and modules. Therefore the creating_config state cannot assign the ownership of the configuration directory to this user. I suggest to gather all necessary information from the PodSpec in the first (new) state, store all information in a struct in the PodState and disregard the PodSpec in all other states.

@siegfriedweber
Copy link
Copy Markdown
Member Author

Fixes #79
Fixes #31

Copy link
Copy Markdown
Member

@soenkeliebau soenkeliebau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a few comments/questions that we could discuss, but overall I'd be happy for this to go in as is as well.
Nit: when running clippy from the nightly toolchain there are two complaints.

Comment thread src/fsext.rs
Comment thread src/fsext.rs
Comment thread src/fsext.rs
Comment thread src/fsext.rs
Comment thread src/provider/systemdmanager/systemdunit.rs
Comment thread src/provider/systemdmanager/systemdunit.rs Outdated
Comment thread src/provider/systemdmanager/systemdunit.rs
Comment thread src/provider/systemdmanager/systemdunit.rs
Comment thread src/provider/states/creating_config.rs Outdated
Comment thread src/provider/systemdmanager/systemdunit.rs Outdated
Copy link
Copy Markdown
Member

@lfrancke lfrancke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor stuff

Comment thread src/provider/systemdmanager/systemdunit.rs
Comment thread src/provider/systemdmanager/systemdunit.rs
Comment thread src/provider/systemdmanager/systemdunit.rs Outdated
Comment thread src/provider/systemdmanager/systemdunit.rs Outdated
WantedBy=multi-user.target"#}
),
)]
fn create_unit_from_pod(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fabulous and I'm fine with merging as is but it's not testing any of the error cases like a wrong user name

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is correct that nearly every line on the happy path is tested but the exception path is ignored. It is definitely worth to test the error cases, too. But my goal is to parse and validate the PodSpec in a first step and then pass this valid structure around where further validation is not necessary. This keeps the tests in the downstream modules comprehensible. Otherwise it would be necessary to define a full PodSpec to test the regular expression for user names and another full PodSpec to test the order of the environment variables and so on. If everything is tested where it belongs to then the tests can be reduced to 3-liners.

@siegfriedweber siegfriedweber merged commit 3affd61 into stackabletech:main Mar 11, 2021
@siegfriedweber siegfriedweber deleted the run_as_user branch March 11, 2021 10:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support running of services as application users Make generation of systemd unit files deterministic

3 participants